<?php

namespace App\Models;


use App\Service\Base\Model;
use Illuminate\Support\Facades\DB;

class UserProfit2 extends Model
{

    // 综合每一笔交易的记录

    // 用户收益表
    protected $table = 'user_profit2';

    // 缓存字段，用于搜索绑定的字段
    protected $cacheFields = ['id', 'uid', 'form_uid', 'type',];

    //  {"id":"","uid":"用户ID","order_id":"用于计算用户冻结资金等","form_uid":"一级ID","total":"消费总数","auth_profit":"认证收益","order_profit":"报名收益","agent_profit":"代理收益","share_profit":"分享收益","publish_profit":"发布收益","description":"描述","ctime":"注册时间","mtime":"更新时间"}


    // array ( 'id' => '$this->getData("id", null, "trim")', 'uid' => '$this->getData("uid", null, "trim")', 'order_id' => '$this->getData("order_id", null, "trim")', 'form_uid' => '$this->getData("form_uid", null, "trim")', 'total' => '$this->getData("total", null, "trim")', 'auth_profit' => '$this->getData("auth_profit", null, "trim")', 'order_profit' => '$this->getData("order_profit", null, "trim")', 'agent_profit' => '$this->getData("agent_profit", null, "trim")', 'share_profit' => '$this->getData("share_profit", null, "trim")', 'publish_profit' => '$this->getData("publish_profit", null, "trim")', 'description' => '$this->getData("description", null, "trim")', 'ctime' => '$this->getData("ctime", null, "trim")', 'mtime' => '$this->getData("mtime", null, "trim")', )


    // $id = $this->getData("id", null, 'trim'); $uid = $this->getData("uid", null, 'trim'); $order_id = $this->getData("order_id", null, 'trim'); $form_uid = $this->getData("form_uid", null, 'trim'); $total = $this->getData("total", null, 'trim'); $auth_profit = $this->getData("auth_profit", null, 'trim'); $order_profit = $this->getData("order_profit", null, 'trim'); $agent_profit = $this->getData("agent_profit", null, 'trim'); $share_profit = $this->getData("share_profit", null, 'trim'); $publish_profit = $this->getData("publish_profit", null, 'trim'); $description = $this->getData("description", null, 'trim'); $ctime = $this->getData("ctime", null, 'trim'); $mtime = $this->getData("mtime", null, 'trim');

    // 支付类型
    public function getType($getKey = true)
    {
        $channels = [
            'auth'  => '认证',
            'order' => '订单',
        ];

        if(empty($getKey)){
            return $channels;
        }

        return array_keys($channels);
    }

    // 定义验证操作
    public function rules()
    {

        $add = [
        ];

        $edit = [
        ];

        $info = [
        ];


        $rule = [
            //'id'             => 'required',
            'uid'            => 'number',
            'order_id'       => 'number',
            'form_uid'       => 'number',
            'total'          => 'number',
            'auth_profit'    => 'number',
            'order_profit'   => 'number',
            'agent_profit'   => 'number',
            'share_profit'   => 'number',
            'publish_profit' => 'number',
            //'description'    => 'required',
            //'ctime'          => 'required',
            //'mtime'          => 'required',
        ];


        $msg = [
            'id'             => '自编号',
            'uid'            => '用户ID',
            'order_id'       => '用于计算用户冻结资金等',
            'form_uid'       => '一级ID',
            'total'          => '消费总数',
            'auth_profit'    => '认证收益',
            'order_profit'   => '报名收益',
            'agent_profit'   => '代理收益',
            'share_profit'   => '分享收益',
            'publish_profit' => '发布收益',
            'description'    => '描述',
            'ctime'          => '注册时间',
            'mtime'          => '更新时间',
        ];

        return ['rule' => $rule, 'msg' => $msg, 'add' => $add];
    }
}
